# coding=utf-8
from application import app

def create_food_json(food, key_list=[]) :
    json = {}
    if "id" in key_list :
        json["id"] = food.id
    if "name" in key_list :
        json["name"] = food.name
    if "image" in key_list :
        json["image"] = app.config["APP"]["domain"] + "/static/upload/" + food.main_image,
    if "discount" in key_list :
        json["discount"] = food.discount
    if "present_price" in key_list :
        json["present_price"] = float(food.present_price)
    if "original_price" in key_list :
        json["original_price"] = float(food.original_price)
    if "is_recommend" in key_list :
        json["is_recommend"] = float(food.is_recommend)
    if "is_discount" in key_list :
        json["is_discount"] = float(food.is_discount)
    if "created_time" in key_list :
        json["created_time"] = str(food.created_time)
    if "updated_time" in key_list :
        json["updated_time"] = str(food.updated_time)
    if "shop_id" in key_list :
        json["shop_id"] = str(food.shop_id)

    return json




